var deviceReady = false;

function selectPicture( elementId ) {
    navigator.camera.getPicture(
        function(uri) {
            $("#"+elementId).css("background-image","url("+uri+")");
        },
        function(e) {
            console.log("Error getting picture: " + e);
            document.getElementById('camera_status').innerHTML = "Error getting picture.";
        },
        { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, allowEdit:true, correctOrientation:true});
};

function takePicture( elementId ) {
    navigator.camera.getPicture(
        function(uri) {
            $("#"+elementId).css("background-image","url("+uri+")");
        },
        function(e) {
            console.log("Error getting picture: " + e);
            document.getElementById('camera_status').innerHTML = "Error getting picture.";
        },
        { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.CAMERA, allowEdit:true, correctOrientation:true});
};

 function selectVideo( ) {
    navigator.camera.getPicture(
	function(uri) {
		$("#uploadVideoUrl").attr("value",uri);
		alert("파일 선택 완료");
    },
	function(e) {
        console.log("Error getting picture: " + e);
		document.getElementById('camera_status').innerHTML = "Error getting picture.";
    },
	{ quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, allowEdit:true, correctOrientation:true});
};

$(document).ready(function()
{
 	document.addEventListener("deviceready", function() {deviceReady = true;}, false);
	window.setTimeout(function() {
        if (!deviceReady) {
            alert("Error: PhoneGap did not initialize.  Camera will not run correctly.");
        }
    },2000);
})

